Skip to content

Add per-bot fallback model for transient failures and quota limits - #381

Merged
d41sys merged 1 commit into
mainfrom
issue-374-fallback-model
Dec 4, 2026
Merged

d41sys merged 1 commit into
mainfrom
issue-374-fallback-model

Conversation

@d41sys

@d41sys d41sys commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

Lets each bot configure an optional fallback model so turns, unattended Routines, and Checks automatically recover when the primary model fails due to rate limits (HTTP 429), quota exhaustion (usage_limit_exceeded / insufficient_quota), 5xx server errors, or network/stream errors:

  • Protocol (proto/src/lib.rs, PROTOCOL.md): Adds Op::FallbackModel { model } and Event::Fallback { from, to, error }, plus optional fallbackModel on set_bot and Bot.
  • Engine (agentcore/src/{model,turn,main,acp}.rs): Tracks fallback_eligible and streamed on model failures. When the primary model fails before streaming any output — immediately on quota 429, or after primary retries exhaust on rate-limit 429 / 5xx / network errors — Turn::stream_until emits Event::Fallback and switches to the fallback model for the rest of that turn (returning to the primary model on the next turn).
  • Service & Store (appd/src/{store,core}.rs): Adds fallback_models (in BOT_TABLES, ON DELETE CASCADE), validates fallbackModel via check_model, persists it across restarts, and forwards Op::FallbackModel on engine start and set_bot.
  • UI (window/ui, native): Renders fallback transcript entries as a quiet status line in both chat views, and adds a Fallback group with a Fallback model picker in Bot Settings (refreshing Bot Settings snapshots; visually verified in light and dark themes).

Closes #374.

Evidence

  • cd window/ui && npm ci && npm run build && npm test: passed (142/142 tests, including new chat.test.ts fallback entry test).
  • cargo fmt --all --check: passed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed.
  • cargo test --workspace --locked --no-fail-fast: passed across all crates, including:
    • agentcore/tests/engine.rs::falls_back_to_backup_model_after_primary_503_retries_exhaust_and_on_quota_429
    • appd/tests/service.rs::fallback_model_persists_across_restarts_and_can_be_cleared
    • appd/src/store.rs::deleting_a_bot_or_a_project_leaves_no_row_that_points_at_it (fallback_models cascade verified)
    • native/tests/bot_settings.rs::fallback_model_is_chosen_and_cleared_with_set_bot + visually inspected updated light/dark Bot Settings snapshots.

Merge Danger

Low. Adds a new fallback_models table (listed in BOT_TABLES) and optional fallbackModel field; when unset (the default), engine and service behavior are unchanged.

Device decision

fallbackModel is carried on set_bot and list_bots / open_bot, which are already in ALLOWED_OVER_LAN (alongside set_model). A paired Device may read and change a bot's fallback model, matching set_model and set_bot without weakening check restrictions.

@d41sys
d41sys merged commit f599fa7 into main Dec 4, 2026
5 checks passed
@d41sys
d41sys deleted the issue-374-fallback-model branch December 4, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fallback model per bot for unattended routines and checks

1 participant